<?php

error_reporting(E_ALL);

/**
 * clase contenedora de los metodos que permiten el manejo de datos dentro del
 *
 * @author Venegas Garcia Gerardo
 */

if (0 > version_compare(PHP_VERSION, '5')) {
    die('This file was generated for PHP 5');
}

/**
 * clase encargada de la conexion con la base de datos MYSQL
 *
 * @author Venegas Garcia Gerardo
 */
require_once('class.Conexion.php');

/* user defined includes */
// section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:000000000000088A-includes begin
// section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:000000000000088A-includes end

/* user defined constants */
// section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:000000000000088A-constants begin
// section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:000000000000088A-constants end

/**
 * clase contenedora de los metodos que permiten el manejo de datos dentro del
 *
 * @access public
 * @author Venegas Garcia Gerardo
 */
class Modelo
    extends Conexion
{
    // --- ASSOCIATIONS ---


    // --- ATTRIBUTES ---

    // --- OPERATIONS ---

    /**
     * metodo que permite obtener todas las hileras de una consulta de datos
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function getAllRows()
    {
        // section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:000000000000088B begin
		$sql = "SELECT * FROM detalles";
		return $this->execQuery($sql);
        // section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:000000000000088B end
    }

    /**
     * metodo que permite buscar un registro de datos por identificador
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  id
     * @return mixed
     */
    public function searchById($id)
    {
        // section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:000000000000088D begin
		$sql = "select * from detalles where idDet = '".@$id."'";
		$row0 = $this->execQuery($sql);
		return $row0[0];
        // section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:000000000000088D end
    }

    /**
     * metodo que permite dar de alta un registro de datos(insert)
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  data
     * @return mixed
     */
    public function insert($data)
    {
        // section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:0000000000000890 begin
		$idDet = @$data['idDet'];
		$cantidad = @$data['cantidad'];
		$precio_Venta = @$data['precio_Venta'];
		$idCot = @$data['idCot'];
		$codigo = @$data['codigo'];
		$sql = "insert into detalles (idDet,cantidad,precio_Venta,idCot,codigo) values ('$idDet','$cantidad','$precio_Venta','$idCot','$codigo')";
		$this->execQuery($sql);
		$li = mysql_insert_id();
	
		return $li;
        // section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:0000000000000890 end
    }

    /**
     * metodo que permite modificar un registro de datos existente(update)
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  data
     * @return mixed
     */
    public function update($data)
    {
        // section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:0000000000000893 begin
		$sql = " update detalles set
		idDet='".@$data[idDet]."',
		cantidad = '".@$data[cantidad]."',
		precio_Venta = '".@$data[precio_Venta]."',
		idCot = '".@$data[idCot]."',
		codigo = '".@$data[codigo]."'
		where idDet = '".@$data[idDet]."'";
	
		$this->execQuery($sql);
        // section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:0000000000000893 end
    }

    /**
     * metodo que permite borrar un registro de dato existente(delete)
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  id
     * @return mixed
     */
    public function delete($id)
    {
        // section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:0000000000000896 begin
		$sql= "delete from detalles where idDet = '".@$id[idDet]."'";
		$this->execQuery($sql);
        // section 10-25-3--56--6a6e9ed3:13cf3efb39b:-8000:0000000000000896 end
    }

    /**
     * Retorna un arrelgo del registro por descripcion y retorna nulo si no lo
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  descripcion
     * @return mixed
     */
    public function searchByDescripcion($descripcion)
    {
        // section -87--2-5--50--369d60b7:13d123ed99d:-8000:0000000000000AA8 begin
		$sql = "SELECT * FROM detalles where codigo LIKE '%" .$descripcion. "%'";
		return $this->execQuery($sql);
        // section -87--2-5--50--369d60b7:13d123ed99d:-8000:0000000000000AA8 end
    }

    /**
     * Retorna un arrelgo del registro por fecha y retorna nulo si no lo
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  fecha
     * @param  fecha2
     * @return mixed
     */
    public function searchByFecha($fecha, $fecha2)
    {
        // section 10-25-3--59-38ae6f99:13d12eb824e:-8000:0000000000000AB3 begin
		//$sql = "SELECT * FROM registros where Date(Fecha) BETWEEN '{$fecha}' AND '{$fecha2}'";
		//return $this->execQuery($sql);
        // section 10-25-3--59-38ae6f99:13d12eb824e:-8000:0000000000000AB3 end
    }

    /**
     * Short description of method paginate
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  paginas
     * @return mixed
     */
    public function paginate($paginas)
    {
        // section -64--88-1-70-74113a83:13d2e93d99d:-8000:000000000000118A begin
		
        // section -64--88-1-70-74113a83:13d2e93d99d:-8000:000000000000118A end
    }

} /* end of class Modelo */

?>